package com.qf.dao;

import com.qf.pojo.Permission;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * @Description: 公用常量
 * @Data: 2022/9/15 19:40
 * @Pacakge: com.qf.dao
 * @ClassName: PermissionRepository
 * @Author: fan
 */
public interface PermissionRepository extends JpaRepository<Permission,Integer> {
    @Query(value = "SELECT p.permission_name  FROM " +
            "user u," +
            "role r," +
            "permission p," +
            "user_role ur," +
            "role_permission rp" +
            " WHERE u.id = ur.userid" +
            " AND ur.roleid = r.id " +
            "AND r.id = rp.roleid " +
            "AND rp.permissionid = p.id " +
            "AND u.username = ?1",nativeQuery = true)
    List<String> findPermissionByUsername(String username);
}
